<?php 

function logger() { // var0: operate, var1: string, var2: array , var3: module
	$str1 = "";
	$str2 = "";
	$str3 = "";
	$str4 = "";

	$arg_num = func_num_args();
	if ($arg_num == 1){
		$str1 = "Operate=".func_get_arg(0);
	}	
	if ($arg_num == 2){
		$str1 = "Operate=".func_get_arg(0);
		$a = func_get_arg(1);
		$str2 = a2s($a);
	}
	if ($arg_num == 3){
		$str1 = "Operate=".func_get_arg(0);
		$a = func_get_arg(1);
		$str2 = a2s($a);
		$str3 = "Module=".func_get_arg(2); 
	}
	if ($arg_num == 4){
		$str1 = "Operate=".func_get_arg(0);
		$a = func_get_arg(1);
		$str2 = a2s($a);
		$str3 = "Module=".func_get_arg(2); 
		$str4 = func_get_arg(3); 
	}

	$access = date("Y/m/d-H:i:s");
	$info =  "Time='". $access. "' User=". $_SESSION['UserName']. " Address=".$_SERVER['REMOTE_ADDR']. " ";
	
	define_syslog_variables();
	openlog("FireWall", LOG_PERROR, LOG_LOCAL0);
	syslog(LOG_WARNING, $info. $str1." ". $str2. " ". $str3. " ". $str4);
	closelog();
}

function a2s($a) {
	$s = " ";
	foreach($a as $r) {	
		$k = key($a);
		$s .= $k. '='. $r. ' ';
		next($a);
	}
	return $s;
}

?>
